//
//  LY_Desc_TableViewCell.m
//  iSee
//
//  Created by dllo on 16/8/6.
//  Copyright © 2016年 LY. All rights reserved.
//

#import "SE_Desc_TableViewCell.h"
#import "SE_Item_Model.h"
#import "UIImageView+WebCache.h"

#define WIDTH self.backView.bounds.size.width
#define HEIGHT self.backView.bounds.size.height

@interface SE_Desc_TableViewCell()

@property (nonatomic, retain) UILabel *titleLabel;
@property (nonatomic, retain) UIView *lineView;
@property (nonatomic, retain) UILabel *descLabel;
@property (nonatomic, retain) UILabel *desc1Label;
@property (nonatomic, retain) UIImageView *backView;

@end

@implementation SE_Desc_TableViewCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        self.backView = [[UIImageView alloc]init];
        [self.contentView addSubview:self.backView];
        
        self.titleLabel = [[UILabel alloc]init];
        self.titleLabel.numberOfLines = 0;
        self.titleLabel.font = [UIFont systemFontOfSize:22];
        self.titleLabel.textColor = [UIColor whiteColor];
        [self.backView addSubview:self.titleLabel];
        
        self.lineView = [[UIView alloc]init];
        self.lineView.backgroundColor = [UIColor whiteColor];
        [self.backView addSubview:self.lineView];
        
        self.desc1Label = [[UILabel alloc]init];
        self.desc1Label.textColor = [UIColor colorWithRed:0.76 green:0.75 blue:0.73 alpha:1.0];
        self.desc1Label.numberOfLines = 0;
        [self.backView addSubview:self.desc1Label];
        
        self.descLabel = [[UILabel alloc]init];
        self.descLabel.font = [UIFont systemFontOfSize:20];
        self.descLabel.textColor = [UIColor colorWithRed:0.76 green:0.75 blue:0.73 alpha:1.0];
        [self.backView addSubview:self.descLabel];
        
        
    }
    return self;
}


-(void)layoutSubviews
{
    [super layoutSubviews];
    self.titleLabel.frame = CGRectMake(10, 0, WIDTH - 20, HEIGHT * 0.3);
    self.lineView.frame = CGRectMake(10, HEIGHT * 0.25, WIDTH * 0.8, 1);
    self.descLabel.frame = CGRectMake(10, HEIGHT * 0.3, WIDTH * 0.8, 10);
    self.desc1Label.frame = CGRectMake(10, HEIGHT * 0.35, WIDTH - 20, HEIGHT * 0.4);
    self.backView.frame = self.contentView.bounds;
    
}

-(void)setItemModel:(SE_Item_Model *)itemModel{
    _itemModel = itemModel;
    self.titleLabel.text = itemModel.title;
    
    NSInteger time = itemModel.duration.integerValue;
    NSInteger min = time / 60;
    int sec = time % 60;
    
    self.descLabel.text = [NSString stringWithFormat:@"#%@  /  %ld'%d'", itemModel.category, min, sec];
    self.desc1Label.text = itemModel.desc;
    [self.backView sd_setImageWithURL:[NSURL URLWithString:itemModel.blurred] placeholderImage:[UIImage imageNamed:@"holder"]];
}

@end




























